package gis.uzd_1;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.prefs.Preferences;

import javax.swing.JFrame;

/**
 * Detail frame.
 * 
 * @version 0.1
 * @date 2010-04-23
 * @author Edmundas Matusevicius
 */
public class DetailFrame extends JFrame {
    public DetailFrame() {
        setTitle("Superb GIS Viewer - Details");
        
        // set default/saved window position, dimensions
        
        Preferences root = Preferences.userRoot();
        final Preferences node = root.node("/gis/uzd_1/detail");
        int left = node.getInt("left", 0);
        int top = node.getInt("top", 0);
        int width = node.getInt("width", DEFAULT_WIDTH);
        int height = node.getInt("height", DEFAULT_HEIGHT);
        setBounds(left, top, width, height);
        
        // new window close event handling
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                // save window position, dimensions
                
                node.putInt("left", getX());
                node.putInt("top", getY());
                node.putInt("width", getWidth());
                node.putInt("height", getHeight());
            }
        });
        
        // add details table panel
        
        DetailPanel panel = new DetailPanel();
        add(panel);
    }
    
    private static final int DEFAULT_WIDTH = 800;
    private static final int DEFAULT_HEIGHT = 400;
}
